import React, { Component } from 'react'
import PropTypes from 'prop-types'

export default class Test extends Component {
  /* constructor() {
     super()
     this.timer = null
   } */
  // timer = null
  render () {
    return <div>Test</div>
  }
  handleClick () {
    console.log(1)
  }
  componentDidMount () {
    // 挂载完毕，指挥执行一次
    this.timer = setInterval(() => {
      console.log('hello')
    }, 1000)
    document.addEventListener('click', this.handleClick)
  }
  componentWillUnmount () {
    // !干点啥？
    console.log('componentWillUnmount')
    // 清除定时器
    clearInterval(this.timer)
    // 解绑：事件类型一致，事件回调一致
    document.removeEventListener('click', this.handleClick)
  }
}
